<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class RubyVM::RJIT::ExitCompiler - ruby_vm: Ruby Standard Library Documentation</title>


<script src="../../js/navigation.js" defer></script>
<script src="../../js/search.js" defer></script>
<script src="../../js/search_index.js" defer></script>
<script src="../../js/searcher.js" defer></script>
<script src="../../js/darkfish.js" defer></script>

<script src="../../js/jquery-3.2.0.min.js"></script>

<script src="../../js/vue.min.js"></script>
<script src="../../js/js.cookie.min.js"></script>

<link href="../../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../../css/rdoc.css" rel="stylesheet">
<link href="../../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../../";
  var index_rel_prefix = "../../";
  var darkModeCsseHref = "../../css/rdoc-dm.css"
  var defaultModeCssHref = "../../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../../table_of_contents.html#pages">Pages</a>
    <a href="../../table_of_contents.html#classes">Classes</a>
    <a href="../../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">Object
</div>

        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-i-compile_branch_stub">#compile_branch_stub</a>
    <li ><a href="#method-i-compile_entry_exit">#compile_entry_exit</a>
    <li ><a href="#method-i-compile_entry_stub">#compile_entry_stub</a>
    <li ><a href="#method-i-compile_full_cfunc_return">#compile_full_cfunc_return</a>
    <li ><a href="#method-i-compile_leave_exit">#compile_leave_exit</a>
    <li ><a href="#method-i-compile_side_exit">#compile_side_exit</a>
    <li ><a href="#method-i-count_insn_exit">#count_insn_exit</a>
    <li ><a href="#method-i-iseq_lineno">#iseq_lineno</a>
    <li ><a href="#method-i-pc_to_insn">#pc_to_insn</a>
    <li ><a href="#method-i-save_pc_and_sp">#save_pc_and_sp</a>
    <li ><a href="#method-i-to_value">#to_value</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-RubyVM::RJIT::ExitCompiler">
    <h1 id="class-RubyVM::RJIT::ExitCompiler" class="class">
      class RubyVM::RJIT::ExitCompiler
    </h1>

    <section class="description">
    
    </section>

      <section id="5Buntitled-5D" class="documentation-section">





                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-new" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">new</span><span
                                class="method-args">(= freeze)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File ruby_vm/rjit/exit_compiler.rb, line 3</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span> = <span class="ruby-identifier">freeze</span>

  <span class="ruby-comment"># Used for invalidating a block on entry.</span>
  <span class="ruby-comment"># @param pc [Integer]</span>
  <span class="ruby-comment"># @param asm [RubyVM::RJIT::Assembler]</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">compile_entry_exit</span>(<span class="ruby-identifier">pc</span>, <span class="ruby-identifier">ctx</span>, <span class="ruby-identifier">asm</span>, <span class="ruby-value">cause:</span>)
    <span class="ruby-comment"># Fix pc/sp offsets for the interpreter</span>
    <span class="ruby-identifier">save_pc_and_sp</span>(<span class="ruby-identifier">pc</span>, <span class="ruby-identifier">ctx</span>, <span class="ruby-identifier">asm</span>, <span class="ruby-value">reset_sp_offset:</span> <span class="ruby-keyword">false</span>)

    <span class="ruby-comment"># Increment per-insn exit counter</span>
    <span class="ruby-identifier">count_insn_exit</span>(<span class="ruby-identifier">pc</span>, <span class="ruby-identifier">asm</span>)

    <span class="ruby-comment"># Restore callee-saved registers</span>
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">comment</span>(<span class="ruby-node">&quot;#{cause}: entry exit&quot;</span>)
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">pop</span>(<span class="ruby-constant">SP</span>)
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">pop</span>(<span class="ruby-constant">EC</span>)
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">pop</span>(<span class="ruby-constant">CFP</span>)

    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">mov</span>(<span class="ruby-constant">C_RET</span>, <span class="ruby-constant">Qundef</span>)
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">ret</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-comment"># Set to cfp-&gt;jit_return by default for leave insn</span>
  <span class="ruby-comment"># @param asm [RubyVM::RJIT::Assembler]</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">compile_leave_exit</span>(<span class="ruby-identifier">asm</span>)
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">comment</span>(<span class="ruby-string">&#39;default cfp-&gt;jit_return&#39;</span>)

    <span class="ruby-comment"># Restore callee-saved registers</span>
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">pop</span>(<span class="ruby-constant">SP</span>)
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">pop</span>(<span class="ruby-constant">EC</span>)
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">pop</span>(<span class="ruby-constant">CFP</span>)

    <span class="ruby-comment"># :rax is written by #leave</span>
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">ret</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-comment"># Fire cfunc events on invalidation by TracePoint</span>
  <span class="ruby-comment"># @param asm [RubyVM::RJIT::Assembler]</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">compile_full_cfunc_return</span>(<span class="ruby-identifier">asm</span>)
    <span class="ruby-comment"># This chunk of code expects REG_EC to be filled properly and</span>
    <span class="ruby-comment"># RAX to contain the return value of the C method.</span>

    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">comment</span>(<span class="ruby-string">&#39;full cfunc return&#39;</span>)
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">mov</span>(<span class="ruby-constant">C_ARGS</span>[<span class="ruby-value">0</span>], <span class="ruby-constant">EC</span>)
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">mov</span>(<span class="ruby-constant">C_ARGS</span>[<span class="ruby-value">1</span>], <span class="ruby-value">:rax</span>)
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">call</span>(<span class="ruby-constant">C</span>.<span class="ruby-identifier">rjit_full_cfunc_return</span>)

    <span class="ruby-comment"># TODO: count the exit</span>

    <span class="ruby-comment"># Restore callee-saved registers</span>
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">pop</span>(<span class="ruby-constant">SP</span>)
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">pop</span>(<span class="ruby-constant">EC</span>)
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">pop</span>(<span class="ruby-constant">CFP</span>)

    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">mov</span>(<span class="ruby-constant">C_RET</span>, <span class="ruby-constant">Qundef</span>)
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">ret</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-comment"># @param jit [RubyVM::RJIT::JITState]</span>
  <span class="ruby-comment"># @param ctx [RubyVM::RJIT::Context]</span>
  <span class="ruby-comment"># @param asm [RubyVM::RJIT::Assembler]</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">compile_side_exit</span>(<span class="ruby-identifier">pc</span>, <span class="ruby-identifier">ctx</span>, <span class="ruby-identifier">asm</span>)
    <span class="ruby-comment"># Fix pc/sp offsets for the interpreter</span>
    <span class="ruby-identifier">save_pc_and_sp</span>(<span class="ruby-identifier">pc</span>, <span class="ruby-identifier">ctx</span>.<span class="ruby-identifier">dup</span>, <span class="ruby-identifier">asm</span>) <span class="ruby-comment"># dup to avoid sp_offset update</span>

    <span class="ruby-comment"># Increment per-insn exit counter</span>
    <span class="ruby-identifier">count_insn_exit</span>(<span class="ruby-identifier">pc</span>, <span class="ruby-identifier">asm</span>)

    <span class="ruby-comment"># Restore callee-saved registers</span>
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">comment</span>(<span class="ruby-node">&quot;exit to interpreter on #{pc_to_insn(pc).name}&quot;</span>)
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">pop</span>(<span class="ruby-constant">SP</span>)
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">pop</span>(<span class="ruby-constant">EC</span>)
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">pop</span>(<span class="ruby-constant">CFP</span>)

    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">mov</span>(<span class="ruby-constant">C_RET</span>, <span class="ruby-constant">Qundef</span>)
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">ret</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-comment"># @param asm [RubyVM::RJIT::Assembler]</span>
  <span class="ruby-comment"># @param entry_stub [RubyVM::RJIT::EntryStub]</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">compile_entry_stub</span>(<span class="ruby-identifier">asm</span>, <span class="ruby-identifier">entry_stub</span>)
    <span class="ruby-comment"># Call rb_rjit_entry_stub_hit</span>
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">comment</span>(<span class="ruby-string">&#39;entry stub hit&#39;</span>)
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">mov</span>(<span class="ruby-constant">C_ARGS</span>[<span class="ruby-value">0</span>], <span class="ruby-identifier">to_value</span>(<span class="ruby-identifier">entry_stub</span>))
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">call</span>(<span class="ruby-constant">C</span>.<span class="ruby-identifier">rb_rjit_entry_stub_hit</span>)

    <span class="ruby-comment"># Jump to the address returned by rb_rjit_entry_stub_hit</span>
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">jmp</span>(<span class="ruby-value">:rax</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-comment"># @param ctx [RubyVM::RJIT::Context]</span>
  <span class="ruby-comment"># @param asm [RubyVM::RJIT::Assembler]</span>
  <span class="ruby-comment"># @param branch_stub [RubyVM::RJIT::BranchStub]</span>
  <span class="ruby-comment"># @param target0_p [TrueClass,FalseClass]</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">compile_branch_stub</span>(<span class="ruby-identifier">ctx</span>, <span class="ruby-identifier">asm</span>, <span class="ruby-identifier">branch_stub</span>, <span class="ruby-identifier">target0_p</span>)
    <span class="ruby-comment"># Call rb_rjit_branch_stub_hit</span>
    <span class="ruby-identifier">iseq</span> = <span class="ruby-identifier">branch_stub</span>.<span class="ruby-identifier">iseq</span>
    <span class="ruby-keyword">if</span> <span class="ruby-constant">C</span>.<span class="ruby-identifier">rjit_opts</span>.<span class="ruby-identifier">dump_disasm</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-constant">C</span>.<span class="ruby-identifier">imemo_type_p</span>(<span class="ruby-identifier">iseq</span>, <span class="ruby-constant">C</span>.<span class="ruby-identifier">imemo_iseq</span>) <span class="ruby-comment"># Guard against ISEQ GC at random moments</span>
      <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">comment</span>(<span class="ruby-node">&quot;branch stub hit: #{iseq.body.location.label}@#{C.rb_iseq_path(iseq)}:#{iseq_lineno(iseq, target0_p ? branch_stub.target0.pc : branch_stub.target1.pc)}&quot;</span>)
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">mov</span>(<span class="ruby-value">:rdi</span>, <span class="ruby-identifier">to_value</span>(<span class="ruby-identifier">branch_stub</span>))
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">mov</span>(<span class="ruby-value">:esi</span>, <span class="ruby-identifier">ctx</span>.<span class="ruby-identifier">sp_offset</span>)
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">mov</span>(<span class="ruby-value">:edx</span>, <span class="ruby-identifier">target0_p</span> <span class="ruby-operator">?</span> <span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-value">0</span>)
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">call</span>(<span class="ruby-constant">C</span>.<span class="ruby-identifier">rb_rjit_branch_stub_hit</span>)

    <span class="ruby-comment"># Jump to the address returned by rb_rjit_branch_stub_hit</span>
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">jmp</span>(<span class="ruby-value">:rax</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">private</span>

  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">pc_to_insn</span>(<span class="ruby-identifier">pc</span>)
    <span class="ruby-constant">Compiler</span>.<span class="ruby-identifier">decode_insn</span>(<span class="ruby-constant">C</span>.<span class="ruby-constant">VALUE</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">pc</span>).<span class="ruby-identifier">*</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-comment"># @param pc [Integer]</span>
  <span class="ruby-comment"># @param asm [RubyVM::RJIT::Assembler]</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">count_insn_exit</span>(<span class="ruby-identifier">pc</span>, <span class="ruby-identifier">asm</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-constant">C</span>.<span class="ruby-identifier">rjit_opts</span>.<span class="ruby-identifier">stats</span>
      <span class="ruby-identifier">insn</span> = <span class="ruby-constant">Compiler</span>.<span class="ruby-identifier">decode_insn</span>(<span class="ruby-constant">C</span>.<span class="ruby-constant">VALUE</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">pc</span>).<span class="ruby-identifier">*</span>)
      <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">comment</span>(<span class="ruby-node">&quot;increment insn exit: #{insn.name}&quot;</span>)
      <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">mov</span>(<span class="ruby-value">:rax</span>, (<span class="ruby-constant">C</span>.<span class="ruby-identifier">rjit_insn_exits</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">insn</span>.<span class="ruby-identifier">bin</span>).<span class="ruby-identifier">to_i</span>)
      <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">add</span>([<span class="ruby-value">:rax</span>], <span class="ruby-value">1</span>) <span class="ruby-comment"># TODO: lock</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">if</span> <span class="ruby-constant">C</span>.<span class="ruby-identifier">rjit_opts</span>.<span class="ruby-identifier">trace_exits</span>
      <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">comment</span>(<span class="ruby-string">&#39;rjit_record_exit_stack&#39;</span>)
      <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">mov</span>(<span class="ruby-constant">C_ARGS</span>[<span class="ruby-value">0</span>], <span class="ruby-identifier">pc</span>)
      <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">call</span>(<span class="ruby-constant">C</span>.<span class="ruby-identifier">rjit_record_exit_stack</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-comment"># @param jit [RubyVM::RJIT::JITState]</span>
  <span class="ruby-comment"># @param ctx [RubyVM::RJIT::Context]</span>
  <span class="ruby-comment"># @param asm [RubyVM::RJIT::Assembler]</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">save_pc_and_sp</span>(<span class="ruby-identifier">pc</span>, <span class="ruby-identifier">ctx</span>, <span class="ruby-identifier">asm</span>, <span class="ruby-value">reset_sp_offset:</span> <span class="ruby-keyword">true</span>)
    <span class="ruby-comment"># Update pc (TODO: manage PC offset?)</span>
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">comment</span>(<span class="ruby-node">&quot;save PC#{&#39; and SP&#39; if ctx.sp_offset != 0} to CFP&quot;</span>)
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">mov</span>(<span class="ruby-value">:rax</span>, <span class="ruby-identifier">pc</span>) <span class="ruby-comment"># rax = jit.pc</span>
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">mov</span>([<span class="ruby-constant">CFP</span>, <span class="ruby-constant">C</span>.<span class="ruby-identifier">rb_control_frame_t</span>.<span class="ruby-identifier">offsetof</span>(<span class="ruby-value">:pc</span>)], <span class="ruby-value">:rax</span>) <span class="ruby-comment"># cfp-&gt;pc = rax</span>

    <span class="ruby-comment"># Update sp</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">ctx</span>.<span class="ruby-identifier">sp_offset</span> <span class="ruby-operator">!=</span> <span class="ruby-value">0</span>
      <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">SP</span>, <span class="ruby-constant">C</span>.<span class="ruby-constant">VALUE</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">ctx</span>.<span class="ruby-identifier">sp_offset</span>) <span class="ruby-comment"># sp += stack_size</span>
      <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">mov</span>([<span class="ruby-constant">CFP</span>, <span class="ruby-constant">C</span>.<span class="ruby-identifier">rb_control_frame_t</span>.<span class="ruby-identifier">offsetof</span>(<span class="ruby-value">:sp</span>)], <span class="ruby-constant">SP</span>) <span class="ruby-comment"># cfp-&gt;sp = sp</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">reset_sp_offset</span>
        <span class="ruby-identifier">ctx</span>.<span class="ruby-identifier">sp_offset</span> = <span class="ruby-value">0</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">to_value</span>(<span class="ruby-identifier">obj</span>)
    <span class="ruby-constant">GC_REFS</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">obj</span>
    <span class="ruby-constant">C</span>.<span class="ruby-identifier">to_value</span>(<span class="ruby-identifier">obj</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">iseq_lineno</span>(<span class="ruby-identifier">iseq</span>, <span class="ruby-identifier">pc</span>)
    <span class="ruby-constant">C</span>.<span class="ruby-identifier">rb_iseq_line_no</span>(<span class="ruby-identifier">iseq</span>, (<span class="ruby-identifier">pc</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">iseq</span>.<span class="ruby-identifier">body</span>.<span class="ruby-identifier">iseq_encoded</span>.<span class="ruby-identifier">to_i</span>) <span class="ruby-operator">/</span> <span class="ruby-constant">C</span>.<span class="ruby-constant">VALUE</span>.<span class="ruby-identifier">size</span>)
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">RangeError</span> <span class="ruby-comment"># bignum too big to convert into `unsigned long long&#39; (RangeError)</span>
    <span class="ruby-value">-1</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-compile_branch_stub" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">compile_branch_stub</span><span
                                class="method-args">(ctx, asm, branch_stub, target0_p)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>@param ctx [RubyVM::RJIT::Context] @param asm [RubyVM::RJIT::Assembler] @param branch_stub [RubyVM::RJIT::BranchStub] @param target0_p [TrueClass,FalseClass]</p>

                              <div class="method-source-code" id="compile_branch_stub-source">
            <pre><span class="ruby-comment"># File ruby_vm/rjit/exit_compiler.rb, line 97</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">compile_branch_stub</span>(<span class="ruby-identifier">ctx</span>, <span class="ruby-identifier">asm</span>, <span class="ruby-identifier">branch_stub</span>, <span class="ruby-identifier">target0_p</span>)
  <span class="ruby-comment"># Call rb_rjit_branch_stub_hit</span>
  <span class="ruby-identifier">iseq</span> = <span class="ruby-identifier">branch_stub</span>.<span class="ruby-identifier">iseq</span>
  <span class="ruby-keyword">if</span> <span class="ruby-constant">C</span>.<span class="ruby-identifier">rjit_opts</span>.<span class="ruby-identifier">dump_disasm</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-constant">C</span>.<span class="ruby-identifier">imemo_type_p</span>(<span class="ruby-identifier">iseq</span>, <span class="ruby-constant">C</span>.<span class="ruby-identifier">imemo_iseq</span>) <span class="ruby-comment"># Guard against ISEQ GC at random moments</span>
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">comment</span>(<span class="ruby-node">&quot;branch stub hit: #{iseq.body.location.label}@#{C.rb_iseq_path(iseq)}:#{iseq_lineno(iseq, target0_p ? branch_stub.target0.pc : branch_stub.target1.pc)}&quot;</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">mov</span>(<span class="ruby-value">:rdi</span>, <span class="ruby-identifier">to_value</span>(<span class="ruby-identifier">branch_stub</span>))
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">mov</span>(<span class="ruby-value">:esi</span>, <span class="ruby-identifier">ctx</span>.<span class="ruby-identifier">sp_offset</span>)
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">mov</span>(<span class="ruby-value">:edx</span>, <span class="ruby-identifier">target0_p</span> <span class="ruby-operator">?</span> <span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-value">0</span>)
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">call</span>(<span class="ruby-constant">C</span>.<span class="ruby-identifier">rb_rjit_branch_stub_hit</span>)

  <span class="ruby-comment"># Jump to the address returned by rb_rjit_branch_stub_hit</span>
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">jmp</span>(<span class="ruby-value">:rax</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-compile_entry_exit" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">compile_entry_exit</span><span
                                class="method-args">(pc, ctx, asm, cause:)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Used for invalidating a block on entry. @param pc [Integer] @param asm [RubyVM::RJIT::Assembler]</p>

                              <div class="method-source-code" id="compile_entry_exit-source">
            <pre><span class="ruby-comment"># File ruby_vm/rjit/exit_compiler.rb, line 8</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">compile_entry_exit</span>(<span class="ruby-identifier">pc</span>, <span class="ruby-identifier">ctx</span>, <span class="ruby-identifier">asm</span>, <span class="ruby-value">cause:</span>)
  <span class="ruby-comment"># Fix pc/sp offsets for the interpreter</span>
  <span class="ruby-identifier">save_pc_and_sp</span>(<span class="ruby-identifier">pc</span>, <span class="ruby-identifier">ctx</span>, <span class="ruby-identifier">asm</span>, <span class="ruby-value">reset_sp_offset:</span> <span class="ruby-keyword">false</span>)

  <span class="ruby-comment"># Increment per-insn exit counter</span>
  <span class="ruby-identifier">count_insn_exit</span>(<span class="ruby-identifier">pc</span>, <span class="ruby-identifier">asm</span>)

  <span class="ruby-comment"># Restore callee-saved registers</span>
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">comment</span>(<span class="ruby-node">&quot;#{cause}: entry exit&quot;</span>)
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">pop</span>(<span class="ruby-constant">SP</span>)
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">pop</span>(<span class="ruby-constant">EC</span>)
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">pop</span>(<span class="ruby-constant">CFP</span>)

  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">mov</span>(<span class="ruby-constant">C_RET</span>, <span class="ruby-constant">Qundef</span>)
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">ret</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-compile_entry_stub" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">compile_entry_stub</span><span
                                class="method-args">(asm, entry_stub)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>@param asm [RubyVM::RJIT::Assembler] @param entry_stub [RubyVM::RJIT::EntryStub]</p>

                              <div class="method-source-code" id="compile_entry_stub-source">
            <pre><span class="ruby-comment"># File ruby_vm/rjit/exit_compiler.rb, line 83</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">compile_entry_stub</span>(<span class="ruby-identifier">asm</span>, <span class="ruby-identifier">entry_stub</span>)
  <span class="ruby-comment"># Call rb_rjit_entry_stub_hit</span>
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">comment</span>(<span class="ruby-string">&#39;entry stub hit&#39;</span>)
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">mov</span>(<span class="ruby-constant">C_ARGS</span>[<span class="ruby-value">0</span>], <span class="ruby-identifier">to_value</span>(<span class="ruby-identifier">entry_stub</span>))
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">call</span>(<span class="ruby-constant">C</span>.<span class="ruby-identifier">rb_rjit_entry_stub_hit</span>)

  <span class="ruby-comment"># Jump to the address returned by rb_rjit_entry_stub_hit</span>
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">jmp</span>(<span class="ruby-value">:rax</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-compile_full_cfunc_return" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">compile_full_cfunc_return</span><span
                                class="method-args">(asm)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Fire cfunc events on invalidation by TracePoint @param asm [RubyVM::RJIT::Assembler]</p>

                              <div class="method-source-code" id="compile_full_cfunc_return-source">
            <pre><span class="ruby-comment"># File ruby_vm/rjit/exit_compiler.rb, line 41</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">compile_full_cfunc_return</span>(<span class="ruby-identifier">asm</span>)
  <span class="ruby-comment"># This chunk of code expects REG_EC to be filled properly and</span>
  <span class="ruby-comment"># RAX to contain the return value of the C method.</span>

  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">comment</span>(<span class="ruby-string">&#39;full cfunc return&#39;</span>)
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">mov</span>(<span class="ruby-constant">C_ARGS</span>[<span class="ruby-value">0</span>], <span class="ruby-constant">EC</span>)
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">mov</span>(<span class="ruby-constant">C_ARGS</span>[<span class="ruby-value">1</span>], <span class="ruby-value">:rax</span>)
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">call</span>(<span class="ruby-constant">C</span>.<span class="ruby-identifier">rjit_full_cfunc_return</span>)

  <span class="ruby-comment"># TODO: count the exit</span>

  <span class="ruby-comment"># Restore callee-saved registers</span>
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">pop</span>(<span class="ruby-constant">SP</span>)
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">pop</span>(<span class="ruby-constant">EC</span>)
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">pop</span>(<span class="ruby-constant">CFP</span>)

  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">mov</span>(<span class="ruby-constant">C_RET</span>, <span class="ruby-constant">Qundef</span>)
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">ret</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-compile_leave_exit" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">compile_leave_exit</span><span
                                class="method-args">(asm)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Set to cfp-&gt;jit_return by default for leave insn @param asm [RubyVM::RJIT::Assembler]</p>

                              <div class="method-source-code" id="compile_leave_exit-source">
            <pre><span class="ruby-comment"># File ruby_vm/rjit/exit_compiler.rb, line 27</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">compile_leave_exit</span>(<span class="ruby-identifier">asm</span>)
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">comment</span>(<span class="ruby-string">&#39;default cfp-&gt;jit_return&#39;</span>)

  <span class="ruby-comment"># Restore callee-saved registers</span>
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">pop</span>(<span class="ruby-constant">SP</span>)
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">pop</span>(<span class="ruby-constant">EC</span>)
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">pop</span>(<span class="ruby-constant">CFP</span>)

  <span class="ruby-comment"># :rax is written by #leave</span>
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">ret</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-compile_side_exit" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">compile_side_exit</span><span
                                class="method-args">(pc, ctx, asm)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>@param jit [RubyVM::RJIT::JITState] @param ctx [RubyVM::RJIT::Context] @param asm [RubyVM::RJIT::Assembler]</p>

                              <div class="method-source-code" id="compile_side_exit-source">
            <pre><span class="ruby-comment"># File ruby_vm/rjit/exit_compiler.rb, line 64</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">compile_side_exit</span>(<span class="ruby-identifier">pc</span>, <span class="ruby-identifier">ctx</span>, <span class="ruby-identifier">asm</span>)
  <span class="ruby-comment"># Fix pc/sp offsets for the interpreter</span>
  <span class="ruby-identifier">save_pc_and_sp</span>(<span class="ruby-identifier">pc</span>, <span class="ruby-identifier">ctx</span>.<span class="ruby-identifier">dup</span>, <span class="ruby-identifier">asm</span>) <span class="ruby-comment"># dup to avoid sp_offset update</span>

  <span class="ruby-comment"># Increment per-insn exit counter</span>
  <span class="ruby-identifier">count_insn_exit</span>(<span class="ruby-identifier">pc</span>, <span class="ruby-identifier">asm</span>)

  <span class="ruby-comment"># Restore callee-saved registers</span>
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">comment</span>(<span class="ruby-node">&quot;exit to interpreter on #{pc_to_insn(pc).name}&quot;</span>)
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">pop</span>(<span class="ruby-constant">SP</span>)
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">pop</span>(<span class="ruby-constant">EC</span>)
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">pop</span>(<span class="ruby-constant">CFP</span>)

  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">mov</span>(<span class="ruby-constant">C_RET</span>, <span class="ruby-constant">Qundef</span>)
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">ret</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-count_insn_exit" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">count_insn_exit</span><span
                                class="method-args">(pc, asm)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>@param pc [Integer] @param asm [RubyVM::RJIT::Assembler]</p>

                              <div class="method-source-code" id="count_insn_exit-source">
            <pre><span class="ruby-comment"># File ruby_vm/rjit/exit_compiler.rb, line 120</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">count_insn_exit</span>(<span class="ruby-identifier">pc</span>, <span class="ruby-identifier">asm</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-constant">C</span>.<span class="ruby-identifier">rjit_opts</span>.<span class="ruby-identifier">stats</span>
    <span class="ruby-identifier">insn</span> = <span class="ruby-constant">Compiler</span>.<span class="ruby-identifier">decode_insn</span>(<span class="ruby-constant">C</span>.<span class="ruby-constant">VALUE</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">pc</span>).<span class="ruby-identifier">*</span>)
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">comment</span>(<span class="ruby-node">&quot;increment insn exit: #{insn.name}&quot;</span>)
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">mov</span>(<span class="ruby-value">:rax</span>, (<span class="ruby-constant">C</span>.<span class="ruby-identifier">rjit_insn_exits</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">insn</span>.<span class="ruby-identifier">bin</span>).<span class="ruby-identifier">to_i</span>)
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">add</span>([<span class="ruby-value">:rax</span>], <span class="ruby-value">1</span>) <span class="ruby-comment"># TODO: lock</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">if</span> <span class="ruby-constant">C</span>.<span class="ruby-identifier">rjit_opts</span>.<span class="ruby-identifier">trace_exits</span>
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">comment</span>(<span class="ruby-string">&#39;rjit_record_exit_stack&#39;</span>)
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">mov</span>(<span class="ruby-constant">C_ARGS</span>[<span class="ruby-value">0</span>], <span class="ruby-identifier">pc</span>)
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">call</span>(<span class="ruby-constant">C</span>.<span class="ruby-identifier">rjit_record_exit_stack</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-iseq_lineno" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">iseq_lineno</span><span
                                class="method-args">(iseq, pc)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="iseq_lineno-source">
            <pre><span class="ruby-comment"># File ruby_vm/rjit/exit_compiler.rb, line 158</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">iseq_lineno</span>(<span class="ruby-identifier">iseq</span>, <span class="ruby-identifier">pc</span>)
  <span class="ruby-constant">C</span>.<span class="ruby-identifier">rb_iseq_line_no</span>(<span class="ruby-identifier">iseq</span>, (<span class="ruby-identifier">pc</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">iseq</span>.<span class="ruby-identifier">body</span>.<span class="ruby-identifier">iseq_encoded</span>.<span class="ruby-identifier">to_i</span>) <span class="ruby-operator">/</span> <span class="ruby-constant">C</span>.<span class="ruby-constant">VALUE</span>.<span class="ruby-identifier">size</span>)
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">RangeError</span> <span class="ruby-comment"># bignum too big to convert into `unsigned long long&#39; (RangeError)</span>
  <span class="ruby-value">-1</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-pc_to_insn" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">pc_to_insn</span><span
                                class="method-args">(pc)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="pc_to_insn-source">
            <pre><span class="ruby-comment"># File ruby_vm/rjit/exit_compiler.rb, line 114</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">pc_to_insn</span>(<span class="ruby-identifier">pc</span>)
  <span class="ruby-constant">Compiler</span>.<span class="ruby-identifier">decode_insn</span>(<span class="ruby-constant">C</span>.<span class="ruby-constant">VALUE</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">pc</span>).<span class="ruby-identifier">*</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-save_pc_and_sp" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">save_pc_and_sp</span><span
                                class="method-args">(pc, ctx, asm, reset_sp_offset: true)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>@param jit [RubyVM::RJIT::JITState] @param ctx [RubyVM::RJIT::Context] @param asm [RubyVM::RJIT::Assembler]</p>

                              <div class="method-source-code" id="save_pc_and_sp-source">
            <pre><span class="ruby-comment"># File ruby_vm/rjit/exit_compiler.rb, line 137</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">save_pc_and_sp</span>(<span class="ruby-identifier">pc</span>, <span class="ruby-identifier">ctx</span>, <span class="ruby-identifier">asm</span>, <span class="ruby-value">reset_sp_offset:</span> <span class="ruby-keyword">true</span>)
  <span class="ruby-comment"># Update pc (TODO: manage PC offset?)</span>
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">comment</span>(<span class="ruby-node">&quot;save PC#{&#39; and SP&#39; if ctx.sp_offset != 0} to CFP&quot;</span>)
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">mov</span>(<span class="ruby-value">:rax</span>, <span class="ruby-identifier">pc</span>) <span class="ruby-comment"># rax = jit.pc</span>
  <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">mov</span>([<span class="ruby-constant">CFP</span>, <span class="ruby-constant">C</span>.<span class="ruby-identifier">rb_control_frame_t</span>.<span class="ruby-identifier">offsetof</span>(<span class="ruby-value">:pc</span>)], <span class="ruby-value">:rax</span>) <span class="ruby-comment"># cfp-&gt;pc = rax</span>

  <span class="ruby-comment"># Update sp</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">ctx</span>.<span class="ruby-identifier">sp_offset</span> <span class="ruby-operator">!=</span> <span class="ruby-value">0</span>
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">SP</span>, <span class="ruby-constant">C</span>.<span class="ruby-constant">VALUE</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">ctx</span>.<span class="ruby-identifier">sp_offset</span>) <span class="ruby-comment"># sp += stack_size</span>
    <span class="ruby-identifier">asm</span>.<span class="ruby-identifier">mov</span>([<span class="ruby-constant">CFP</span>, <span class="ruby-constant">C</span>.<span class="ruby-identifier">rb_control_frame_t</span>.<span class="ruby-identifier">offsetof</span>(<span class="ruby-value">:sp</span>)], <span class="ruby-constant">SP</span>) <span class="ruby-comment"># cfp-&gt;sp = sp</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">reset_sp_offset</span>
      <span class="ruby-identifier">ctx</span>.<span class="ruby-identifier">sp_offset</span> = <span class="ruby-value">0</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-to_value" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">to_value</span><span
                                class="method-args">(obj)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="to_value-source">
            <pre><span class="ruby-comment"># File ruby_vm/rjit/exit_compiler.rb, line 153</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">to_value</span>(<span class="ruby-identifier">obj</span>)
  <span class="ruby-constant">GC_REFS</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">obj</span>
  <span class="ruby-constant">C</span>.<span class="ruby-identifier">to_value</span>(<span class="ruby-identifier">obj</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is a service of <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>, purveyors of fine <a href='https://jamesbritt.bandcamp.com/'>dance noise</a></p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

